<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Comments extends Model
{
    use HasFactory;
    protected $table = 'store_comments';
    protected $guarded = [];

    //查询上级评论的状态是否正常
    public static function commentStatus(int $parentId)
    {
        $comment = self::where('id', $parentId)
            ->where('status', '1')
            ->where('is_del', '0')
            ->first();
        return $comment ? $comment->toArray() : Null;
    }

    //添加一条评论
    public static function topComments($params = array())
    {
        return self::create($params);
    }
}
